var t = require("../../../@babel/runtime/helpers/defineProperty"), e = getApp();

Page({
    data: {
        query: {
            cstore_id: null,
            coupon_member_kwd: "",
            clerk_member_kwd: "",
            order_sn: "",
            goods_name: "",
            start_time: "",
            end_time: ""
        },
        isLoadMore: !0,
        page: 1,
        totalPage: 0,
        examineList: [],
        startShow: !1,
        endShow: !1,
        currentDate: new Date().getTime(),
        terminateDate: new Date().getTime(),
        minDate: new Date().getTime(),
        startDate: "",
        endDate: "",
        formatter: function(t, e) {
            return "year" === t ? "".concat(e, "年") : "month" === t ? "".concat(e, "月") : e;
        }
    },
    onLoad: function(t) {
        var e;
        console.log(t);
        var a = new Date().getFullYear(), n = new Date(new Date().setFullYear(a - 10)).getTime();
        console.log(n), console.log(a), "" !== (null !== (e = t.storeId) && void 0 !== e ? e : "") && (this.setData({
            "query.cstore_id": parseInt(t.storeId),
            minDate: n
        }), this.examineList());
    },
    startTimeOn: function() {
        this.setData({
            startShow: !0
        });
    },
    endTimeOn: function() {
        this.setData({
            endShow: !0
        });
    },
    formatDate: function(t) {
        return t = new Date(t), "".concat(t.getFullYear(), "-").concat(t.getMonth() + 1, "-").concat(t.getDate());
    },
    modelInput: function(e) {
        var a = e.currentTarget.dataset.name, n = e.detail;
        this.setData(t({}, a, n));
    },
    onSearch: function() {
        console.log(this.data.query), this.examineList();
    },
    onClose: function(t) {
        "start" === t.currentTarget.dataset.state ? this.setData({
            startShow: !1,
            startDate: "",
            "query.start_time": ""
        }) : this.setData({
            endShow: !1,
            endDate: "",
            "query.end_time": ""
        });
    },
    onConfirm: function(t) {
        var e = t.currentTarget.dataset.state, a = Math.round(new Date(t.detail).getTime() / 1e3), n = new Date(new Date(new Date(t.detail).toLocaleDateString()).getTime() + 864e5 - 1) / 1e3;
        "start" === e ? this.setData({
            startShow: !1,
            startDate: this.formatDate(t.detail),
            "query.start_time": a
        }) : this.setData({
            endShow: !1,
            endDate: this.formatDate(t.detail),
            "query.end_time": parseInt(n)
        });
    },
    examineList: function() {
        var t = this, a = e.getNetAddresss("plugin.coupon-store.frontend.store-manage.examineList"), n = this.data.query;
        n.page = this.data.page, e._postNetWork({
            url: a,
            data: n,
            success: function(e) {
                var a = e.data;
                wx.hideLoading(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh(), 1 == a.result ? (t.data.isLoadMore = !0, 
                t.data.totalPage = a.data.last_page, t.data.totalPage || (t.data.totalPage = 0), 
                t.setData({
                    examineList: a.data.data
                })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.totalPage)) {
            this.data.page = this.data.page + 1;
            var a = e.getNetAddresss("plugin.coupon-store.frontend.store-manage.examineList"), n = this.data.query;
            n.page = this.data.page, e._getNetWork({
                url: a,
                data: n,
                success: function(e) {
                    var a = e.data, n = a.data.data;
                    1 == a.result ? (t.data.isLoadMore = !0, t.setData({
                        examineList: t.data.examineList.concat(n)
                    })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), wx.showLoading({
            title: "刷新中..."
        }), this.setData({
            page: 1
        }), this.examineList();
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {}
});